﻿using MikuMikuModel.Logs;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ft_module_parser.aftconversion.ppd
{
    static class from_config
    {
        public static string nico_user;
        public static string nico_pass;
        public static void do_convert()
        {
            var argv = "";
            var argn = "";
            var reso = "";
            var nico = "";
            var audiobitrate = "500";

            if (!File.Exists("divamods_ppd.txt"))
            {
                Console.WriteLine("divamods_ppd.txt not found");
                Console.ReadKey();
                return;
            }

            using (StreamReader modtxt = new StreamReader("divamods_ppd.txt"))
            {
                while (modtxt.Peek() >= 0)
                {
                    var line = modtxt.ReadLine();
                    int index = line.IndexOf('=');
                    if (!(line.StartsWith("#")) && (index > 0))
                    {
                        string first = line.Substring(0, index);
                        string second = line.Substring(index + 1);

                        if (first == "nico_user")
                            nico_user = second;

                        if (first == "nico_pass")
                            nico_pass = second;

                        if (first == "format")
                            reso = second;

                        if (first == "formatnico")
                            nico = second;

                        if (first == "oggbitrate")
                            audiobitrate = second;

                        if (first == "argv")
                            argv = second;

                    }
                }
            }
            ppd.mass_convert.Convert("", argv, reso, nico, audiobitrate);
        }
    }
}
